import { defineStore } from 'pinia'
import { queryRightsRequest, queryRoleListRequest, queryInterfaceListRequest } from '@/network/api/rights-api'

export const usePermissStore = defineStore('permiss', {
  state: () => {
    return {
      permissionList: <any>[],
      roleList: <any>[],
      interfaceList: <any>[],
    }
  },
  actions: {
    async permissionPageInit() {
      const result = await queryRightsRequest()
      const roleList = await queryRoleListRequest()
      this.permissionList = result.result
      this.roleList = roleList.result.data
    },
    async interfacePageInit() {
      const result = await queryInterfaceListRequest()
      const roleList = await queryRoleListRequest()
      this.interfaceList = result.result
      this.roleList = roleList.result.data
    },
  },
})
